<template>
  <div style="font-size: 20px">
    <img src="../../../../assets/image/jianshe/title.png" alt="" />
    项目交付情况
  </div>
  <div class="w-100 h-100" style="position: relative">
    <div
      style="width: 100%; height: 10%; position: absolute; top: 0; right: 0"
      class="d-flex justify-content-end"
    >
      <FakeLegend
        style="margin: auto 30px auto 0px"
        :color="colorSingleList"
        :text="['预计交付数量', '实际交付数量']"
      >
      </FakeLegend>
    </div>
    <div class="bottom">
      <div id="zhi2" style="width: 100%; height: 100%"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import * as echarts from "echarts";
import { useOptions } from "@/hook/useOptions";
import FakeLegend from "@/components/project/fakeLegend.vue";
import {chartOptions} from '@/hook/chartOptions' 

const colorSingleList = ["rgba(3, 230, 254, 1)", "rgba(184, 235, 143, 1)"];

const jsonData: any = inject("jsonData");
const props = defineProps({
  allData: {
    type: Object,
    default: () => ({}),
  },
  selectValue: {
    default: 0,
  },
});

const current = computed(() => {
  
  let data = [[], []];
  try {
    data = props.allData[props.selectValue];
  } catch (error) {}

  return data;
});
let myChart1: any;

watch(
  () => current.value,
  (val) => {
    console.log(val,'valva2');
    
    if (val) {
      myChart1.setOption({
        series: [{ data: val[0] }, { data: val[1] }],
      });
    }
  }
);

onMounted(() => {
  const option:any = chartOptions().twoBarOption(echarts, ['预计交付数量', '实际交付数量'])
  option.xAxis[0].data = useOptions().year();
  option.yAxis[0].name = '个'
  console.log(option.series,'option.series');
  
  myChart1 = echarts.init(document.getElementById("zhi2") as HTMLElement);
  myChart1.setOption(option);
});

</script>

<style lang="less" scoped>
.bottom {
  width: 100%;
  height: 84%;
  display: flex;
}
</style>
